package top.fzqblog.function

/**
 * Created by 抽离 on 2017/8/2 0002.
 */
fun <T> max(collection: Collection<out T>, less: (T, T) -> Boolean
): T? {
    var max: T? = null
    for (it in collection)
        if (max == null || less(max!!, it))
            max = it
    return max
}

fun main(args: Array<String>) {
    println(max(listOf(1, 2 ,3), {x , y -> x<y}))
}